#!/bin/bash


export LD_LIBRARY_PATH=/usr/lib:/opt/hsc/lib:$LD_LIBRARY_PATH
CLASSPATH=/usr/websm/codebase/pluginjars/ccfw.jar:/usr/websm/codebase/pluginjars/auifw.jar:/opt/hsc/:/usr/websm/codebase/pluginjars/hsc.jar:/usr/websm/codebase/pluginjars/sniacimom.jar:/usr/websm/codebase/pluginjars/xerces.jar:/usr/websm/codebase/wsm.jar:/usr/websm/codebase/pluginjars/hsc.jar:$CLASSPATH
export CLASSPATH
export PATH=/opt/IBMJava/jre/bin:$PATH

x=`java com.ibm.hsc.common.util.HSCVPD | grep Model`
if [ $? -eq 0 ]
then

   # Handle case where on rack mount VPD is enclosed in bracket
   # VPD returned has the form eServer xSeries  [7315R01]

   echo $x | grep "\[" 2>&1 >/dev/null
   if [ $? -eq 0 ]
   then
     cmodel=`echo $x | cut -d':' -f2 | cut -d'[' -f 2 | cut -d ']' -f 1 | cut -c1-4`

     mtype=`echo $x | cut -d':' -f2 | cut -d'[' -f 2 | cut -d ']' -f 1 | cut -c5-7`
   else
     cmodel=`echo $x | cut -d':' -f2 | cut -c2-5`
     mtype=`echo $x | cut -d':' -f2 | cut -c6-8`
   fi
   if [ "$1" = "-a" ]
   then
     serial=`java com.ibm.hsc.common.util.HSCVPD | grep Serial`
     sn=`echo $serial | cut -d':' -f 2 | cut -c2-`
     echo "$cmodel$mtype*$sn"
   else
     echo "$cmodel$mtype"
   fi 
   exit 0
else
   exit 1
fi
